filechooser: Fix crash when file has no content-type
authorBastien Nocera <hadess@hadess.net>
Fri, 28 Feb 2020 15:56:29 +0000 (16:56 +0100)
committerBastien Nocera <hadess@hadess.net>
Fri, 28 Feb 2020 16:32:48 +0000 (17:32 +0100)
This might happen for slow filesystems where a fast-content-type might
be provided instead. Don't try to manipulate that content_type if it's
NULL, otherwise we'll either throw warnings (at best) or crash (at
worse).

Conflicts:
gtk/gtkfilechooserwidget.c

gtk/gtkfilechooserwidget.c

index 946066346873d3c263ee15cdd0a3e60ab18c7d6d..adee2ab5d8211e82d7198d5a1d227e200e2f93f7 100644 (file)
@@ -4599,6 +4599,9 @@ get_type_information (GtkFileChooserWidget *impl,
 
   GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
   content_type = g_file_info_get_content_type (info);
+  if (!content_type)
+    goto end;
+
   switch (priv->type_format)
     {
     case TYPE_FORMAT_MIME:
@@ -4616,6 +4619,7 @@ get_type_information (GtkFileChooserWidget *impl,
       g_assert_not_reached ();
     }
 
+end:
   return g_strdup ("");
 }